package com.hl.card.modular.packBack.controller;


import com.hl.card.common.controller.BaseController;
import com.hl.card.common.persistence.model.BibivipRecord;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.hl.card.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.hl.card.modular.packBack.service.IBibivipRecordService;

/**
 * bibivipRecord控制器
 *
 * @author fengshuonan
 * @Date 2018-09-21 15:12:15
 */
@Controller
@RequestMapping("/bibivipRecord")
public class BibivipRecordController extends BaseController {

    private String PREFIX = "/packback/bibivipRecord/";

    @Autowired
    private IBibivipRecordService bibivipRecordService;

    /**
     * 跳转到bibivipRecord首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "bibivipRecord.html";
    }

    /**
     * 跳转到添加bibivipRecord
     */
    @RequestMapping("/bibivipRecord_add")
    public String bibivipRecordAdd() {
        return PREFIX + "bibivipRecord_add.html";
    }

    /**
     * 跳转到修改bibivipRecord
     */
    @RequestMapping("/bibivipRecord_update/{bibivipRecordId}")
    public String bibivipRecordUpdate(@PathVariable Integer bibivipRecordId, Model model) {
        BibivipRecord bibivipRecord = bibivipRecordService.selectById(bibivipRecordId);
        model.addAttribute("item",bibivipRecord);
        LogObjectHolder.me().set(bibivipRecord);
        return PREFIX + "bibivipRecord_edit.html";
    }

    /**
     * 获取bibivipRecord列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return bibivipRecordService.selectList(null);
    }

    /**
     * 新增bibivipRecord
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(BibivipRecord bibivipRecord) {
        bibivipRecordService.insert(bibivipRecord);
        return SUCCESS_TIP;
    }

    /**
     * 删除bibivipRecord
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer bibivipRecordId) {
        bibivipRecordService.deleteById(bibivipRecordId);
        return SUCCESS_TIP;
    }

    /**
     * 修改bibivipRecord
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(BibivipRecord bibivipRecord) {
        bibivipRecordService.updateById(bibivipRecord);
        return SUCCESS_TIP;
    }

    /**
     * bibivipRecord详情
     */
    @RequestMapping(value = "/detail/{bibivipRecordId}")
    @ResponseBody
    public Object detail(@PathVariable("bibivipRecordId") Integer bibivipRecordId) {
        return bibivipRecordService.selectById(bibivipRecordId);
    }
}
